layui.config({
        base: '/assets/module/'
}).extend({
    notice: 'notice/notice',
    dropdown: 'dropdown/dropdown',
    cascader: 'cascader/cascader',
    Cropper: 'Cropper/Cropper',
    tagsInput: 'tagsInput/tagsInput',
    fileChoose: 'fileChoose/fileChoose',
    imgChoose: 'imgChoose/imgChoose',
}).use(['layer', 'form', 'formX', 'setter', 'mynotice', 'cookie', 'admin', 'ax', 'util', 'notice', 'cascader', 'dropdown', 'element', 'table', 'dataGrid', 'laydate'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var formX = layui.formX;
    var setter = layui.setter;
    var mynotice = layui.mynotice;
    var notice = layui.notice;
    var cookie = layui.cookie;
    var admin = layui.admin;
    var $ax = layui.ax;
    var util = layui.util;
    var cascader = layui.cascader;
    var dropdown = layui.dropdown;  // 加载模块
    var laydate = layui.laydate;
    
    var citydatas = [];
    
    layui.table.set({
        headers: {'X-Requested-With': 'XMLHttpRequest'},
        parseData: function(res) {
            if(res.code == 401) {
            	layui.notice.warning({
        			title: '系统提示',
        			message: '登录状态已过期，您可以继续留在该页面，或者重新登录',
        			position: 'center', // 显示位置
        			transitionIn: 'fadeIn', // 进入动画
        			transitionOut: 'fadeOut', // 退出动画
        			timeout: false, // 消失时间
        			progressBar: false, // 进度条
        			close: false, // 关闭按钮
        			overlay: true, // 遮罩层
        			drag: false, // 滑动关闭
        			displayMode: 2, // 显示模式 0无限制，1同类型存在不显示，2同类型存在先移除
        			buttons: [['<button style="background-color: #fff;border: 1px solid #C9C9C9;">取消</button>', function () {
                        	layui.notice.destroy()
                    	}], ['<button style="color: #fff;background-color: #1890ff;border-color: #1890ff;">重新登录</button>', function () {
                    		location.replace('login.html');
                    	}]]
        		});
            }
            return res;
        }
    });
    
    //鼠标的移入移出
    $(".headerRt-li").mouseover(function () {
        var _this = $(this);
        _this.find(".headerRt-liCol").show()

    }).mouseout(function () {
        var _this = $(this);
        _this.find(".headerRt-liCol").hide()

    });
    
    // 右侧热闻
	var hotNewsDiv = $("#ifFixed");
	if(hotNewsDiv){
		var thatHei = hotNewsDiv.offset();
		if(thatHei){
			var thatTop = thatHei.top;
			codeVal.hotNews(hotNewsDiv , thatTop)
		}
	}

    $(".userEvaluate-Reply").on('click', function () {
        var _this = $(this);
        var frame = _this.parent().parent().siblings(".userEvaluate-liText").find(".minReply-frame");
        frame.slideDown()
    });
    
    var App = {
    	page: 1, // 从第二页开始加载
    	limit: 10, // 一次加载数量
    	lock: false, // 锁
    	hisTime: [], // 从localStorage获取搜索时间的数组
    	hisItem: [], // 从localStorage获取搜索内容的数组
    	firstKey: '', //从localStorage获取最早的1个搜索时间
    	keyword: '', // 搜索关键词
    	cascaderins: {}, // 地区下拉选择对象
    	cascaderData: [], // 地区数据
    	pattern: /^1(3|4|5|7|8)\d{9}$/, // 手机号码校验正则表达式
    	cascaderRender: () => { // 区域渲染
    		if($("#cityCodeCascader").length > 0){
    			App.cascaderins = cascader.render({
                	elem: '#cityCodeCascader',
                	//changeOnSelect: true, // 选择即改变
                	filterable: true, // 搜索功能
                	notFoundText: '没有匹配到数据',
                	itemHeight: '200px',
                	reqData: function (values, callback, data) {
                		if(App.cascaderData.length > 0){
                			callback(App.cascaderData);
                		}else{
                			var ajax = new $ax('/api/city/getDatAll', 'get', function (res) {
                				var str = App.unzip(res.data);
                				App.cascaderData = JSON.parse(str);
                                callback(App.cascaderData); 
                    	    }, function (res) {
                    	    	mynotice.error(res.msg);
                    	    });
                    	    ajax.start();
                		}
                    }
                })
    		}
    	},
    	unzip: (b64Data) => { // 解压gzip
	        const strData = atob(b64Data);
	        const charData = strData.split('').map(function (x) {
	            return x.charCodeAt(0);
	        });
	        const binData = new Uint8Array(charData);
	        const data = pako.inflate(binData);
	        const array = new Uint16Array(data);
	        // 防止一次解压造成内存溢出，这里进行分段解压
	        let result = '';
	        let i = 0;
	        const maxRange = 8 * 1024;
	        for (i = 0; i < array.length / maxRange; i++) {
	            result += String.fromCharCode.apply(null, array.slice(i * maxRange, (i + 1) * maxRange));
	        }
	        result += String.fromCharCode.apply(null, array.slice(i * maxRange));
	        return decodeURIComponent(result);
	    },
    	getQueryString: (name) => { // 获取url中的参数
    		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
            var r = window.location.search.substr(1).match(reg); 
            if (r != null) return r[2]; 
            return null; 
    	},
    	imgLoad: () => {
    		$("img").delayLoading({
    			defaultImg: "/assets/images/Headline61.png",           // 预加载前显示的图片
    			errorImg: "/assets/images/error.jpg",                        // 读取图片错误时替换图片(默认：与defaultImg一样)
    			imgSrcAttr: "originalSrc",           // 记录图片路径的属性(默认：originalSrc，页面img的src属性也要替换为originalSrc)
    			beforehand: 0,                       // 预先提前多少像素加载图片(默认：0)
    			event: "scroll",                     // 触发加载图片事件(默认：scroll)
    			duration: "normal",                  // 三种预定淡出(入)速度之一的字符串("slow", "normal", or "fast")或表示动画时长的毫秒数值(如：1000),默认:"normal"
    			container: window,                   // 对象加载的位置容器(默认：window)
    			success: function (imgObj) { },      // 加载图片成功后的回调函数(默认：不执行任何操作)
    			error: function (imgObj) { }         // 加载图片失败后的回调函数(默认：不执行任何操作)
    		});
    	},
    	recMore: () => { // 推荐加载更多
    		if(!App.lock){
    			App.lock = true;
    			App.page += 1;
        		var ajax = new $ax('/loadmore/rec?page=' + App.page + '&limit=' + App.limit, 'get', function (res) {
        			App.lock = false;
        			if(res.count == 0){
        				App.page -= 1;
        			}
        			if(!res.data.hasNext){
        				$('.sideBar-animate').addClass('layui-hide');
        			}
        			$('#loadli').append(res.data.res);
        			App.imgLoad();
        	    }, function (res) {
        	    	App.lock = false;
        	    	mynotice.error(res.msg);
        	    });
        	    ajax.start();
    		}
    	},
    	searchMore: () => { // 搜索加载更多
    		if(!App.lock){
    			App.lock = true;
    			App.page += 1;
        		var ajax = new $ax('/loadmore/search?page=' + App.page + '&limit=' + App.limit + '&keyword=' + App.keyword, 'get', function (res) {
        			App.lock = false;
        			if(res.count == 0){
        				App.page -= 1;
        			}
        			if(!res.data.hasNext){
        				$('.sideBar-animate').addClass('layui-hide');
        			}
        			$('#searchui').append(res.data.res);
        			App.imgLoad();
        	    }, function (res) {
        	    	App.lock = false;
        	    	mynotice.error(res.msg);
        	    });
        	    ajax.start();
    		}
    	},
    	searchAuthMore: () => { // 作者搜索更多
    		if(!App.lock){
    			App.lock = true;
    			App.page += 1;
        		var ajax = new $ax('/loadmore/searchAuth?page=' + App.page + '&limit=' + App.limit + '&keyword=' + App.keyword, 'get', function (res) {
        			App.lock = false;
        			if(res.count == 0){
        				App.page -= 1;
        			}
        			if(!res.data.hasNext){
        				$('.sideBar-animate').addClass('layui-hide');
        			}
        			$('#userdiarylist').append(res.data.res);
        			App.imgLoad();
        	    }, function (res) {
        	    	App.lock = false;
        	    	mynotice.error(res.msg);
        	    });
        	    ajax.start();
    		}
    	},
    	myMore: (id) => { // 用户文章加载更多
    		if(!App.lock){
    			App.lock = true;
    			App.page += 1;
        		var ajax = new $ax('/loadmore/res?page=' + App.page + '&limit=20&userId=' + id, 'get', function (res) {
        			App.lock = false;
        			if(res.count == 0){
        				App.page -= 1;
        			}
        			if(!res.data.hasNext){
        				$('.sideBar-animate').addClass('layui-hide');
        			}
        			$('#userReslist').append(res.data.res);
        			$('.wall').jaliswall({item: '.article'});
        			App.imgLoad();
        	    }, function (res) {
        	    	App.lock = false;
        	    	mynotice.error(res.msg);
        	    });
        	    ajax.start();
    		}
    	}, 
    	voteMore: (id) => { // 点赞加载更多
    		if(!App.lock){
    			App.lock = true;
    			App.page += 1;
        		var ajax = new $ax('/loadmore/voteMore?page=' + App.page + '&limit=20&userId=' + id, 'get', function (res) {
        			App.lock = false;
        			if(res.count == 0){
        				App.page -= 1;
        			}
        			if(!res.data.hasNext){
        				$('.sideBar-animate').addClass('layui-hide');
        			}
        			$('#userVotelist').append(res.data.res);
        			 $('.wall').jaliswall({item: '.article'});
        			App.imgLoad();
        	    }, function (res) {
        	    	App.lock = false;
        	    	mynotice.error(res.msg);
        	    });
        	    ajax.start();
    		}
    	},
    	collectMore: (id) => { // 收藏加载更多
    		if(!App.lock){
    			App.lock = true;
    			App.page += 1;
        		var ajax = new $ax('/loadmore/collectMore?page=' + App.page + '&limit=20&userId=' + id, 'get', function (res) {
        			App.lock = false;
        			if(res.count == 0){
        				App.page -= 1;
        			}
        			if(!res.data.hasNext){
        				$('.sideBar-animate').addClass('layui-hide');
        			}
        			$('#userCollectlist').append(res.data.res);
        			 $('.wall').jaliswall({item: '.article'});
        			App.imgLoad();
        	    }, function (res) {
        	    	App.lock = false;
        	    	mynotice.error(res.msg);
        	    });
        	    ajax.start();
    		}
    	},
    	searchinit: () => {
    		// 每次执行都把2个数组置空
    		App.hisTime = [];
    		App.hisItem = [];
            // 模拟localStorage本来有的记录
            // localStorage.setItem("a",12333);
            // 本函数内的两个for循环用到的变量
            var i = 0
            for(; i < localStorage.length; i++) {
                if(!isNaN(localStorage.key(i))) {
                	App.hisItem.push(localStorage.getItem(localStorage.key(i)));
                	App.hisTime.push(localStorage.key(i));
                    $('.SearchHistory').show();
                }
            }
            // 执行init(),每次清空之前添加的节点
            $(".delete").html("");
            $.each(App.hisItem, (i, v) => {
            	var searchMsg = '<li class="SearchHistory-li">'+
                '<div class="SearchHistory-liD">'+
                '<span class="SearchHistory-liDs">' + v + '</span>'+
                '</div>'+
                '</li>';
            	$(".delete").prepend(searchMsg);
            })
    	},
    	search: (value) => { // 搜索
            var time = (new Date()).getTime();
            if(!value) {
            	mynotice.info('请输入你要查找的关键词');
            	return false;
            }
            $('.SearchHistory').show();
            if($.inArray(value, App.hisItem) >= 0) { //输入的内容localStorage有记录
                for(var j = 0; j < localStorage.length; j++) {
                    if(value == localStorage.getItem(localStorage.key(j))) {
                        localStorage.removeItem(localStorage.key(j));
                    }
                }
                localStorage.setItem(time, value);
            }else { //输入的内容localStorage没有记录
                //由于限制了只能有6条记录，所以这里进行判断
                if(App.hisItem.length > 3) {
                    firstKey = App.hisTime[0]
                    localStorage.removeItem(firstKey);
                    localStorage.setItem(time, value);
                } else {
                    localStorage.setItem(time, value)
                }
            }
            App.searchinit();
            var q = encodeURIComponent(value);
            App.keyword = q;
            window.location.href ='/search?keyword=' + q;
    	},
    	searchCity: (v) => { // 搜索站点
    		var ajax = new $ax('/api/city/query', 'get', function (res) {
    			var html = '';
    			if(res.data.length > 0){
    				html = '<ul class="city_sug">';
    				$.each(res.data, (i, v) => {
    					html += '<li class=""><a href="javascript:void(0);" data-id="'+ v.aid +'" lay-event="changecity">'+ v.name +'</a></li>';
        			})
        			html += '</ul>';
    			}
    			$('#city_sug').html(html);
    	    }, function (res) {
    	    	mynotice.error(res.msg);
    	    });
    		ajax.set('citySite', v);
    	    ajax.start();
    	},
    	curr: () => {
    		$(".currencySearch").bind('click',function(){
    	        $(".headerNav").hide();
    	        $(".searchBox").show();
    	        $("#searchCon").focus();
    	        $(this).css('border-color','#cdcdcd');
    	        $(this).find('.headerRt-liA-img').css('background-color','#cdcdcd');
    	        $(this).unbind();
    	    });
    	},
    	columnMore: (cid) => { // 栏目加载更多
    		if(!App.lock){
    			App.lock = true;
    			App.page += 1;
        		var ajax = new $ax('/loadmore/column/' + cid + '?page=' + App.page + '&limit=' + App.limit, 'get', function (res) {
        			App.lock = false;
        			if(res.count == 0){
        				App.page -= 1;
        			}
        			if(!res.data.hasNext){
        				$('.sideBar-animate').addClass('layui-hide');
        			}
        			$('#loadli').append(res.data.res);
        			App.imgLoad();
        	    }, function (res) {
        	    	App.lock = false;
        	    	mynotice.error(res.msg);
        	    });
        	    ajax.start();
    		}
    	},
    	helpShop: (title, type) => { // 在线帮助
    		admin.open({
    			type: 1,
    			title: [title, 'color:#ff4200;'],
    			offset: 'auto',
    			area: '450px',
    			content: $('#lookingForAShop').html(),
    			success: function(layero, dIndex){
    				$(layero).children('.layui-layer-content').css('overflow', 'visible'); 
    				App.cascaderRender();
    				var uuid = '';
    				$('#smscodebtn').on('click', function(){
    					var phone = $('#telphone').val();
    					if(!App.pattern.test(phone)){
    						mynotice.infoc('请输入正确的手机号');
    		            	return false;
    		        	}
    					admin.btnLoading('#smscodebtn', '&nbsp;正在发送...'); 
    					var ajax = new $ax('/fast/sms', 'get', function (res) {
    						admin.btnLoading('#smscodebtn', false);
    						uuid = res.data;
    						// 自定义倒计时文字，默认是30s,29s,28s...
            			    formX.startTimer('#smscodebtn', 30, function(time){
            			    	if(time == 1){
            			    		$('#smscodebtn').attr('disabled', false);
            			    	}
            			        return time + 's 后可继续发送';
            			    });
        			    }, function (res) {
        			    	admin.btnLoading('#smscodebtn', false);
        			    	mynotice.error(res.msg);
        			    });
        			    ajax.set('phone', phone);
        			    ajax.start();
    					
    				})
    				
    				/*提交问题*/
    			    form.on('submit(userShopSubmit)', function(data){
    			    	mynotice.load('提交中，请稍后...');
        			    var ajax = new $ax('/zp/helpshop/add', 'post', function (res) {
        			    	mynotice.destroy();
        			    	mynotice.success('提交成功！');
        			    	layer.close(dIndex);
        			    }, function (res) {
        			    	mynotice.destroy();
        			    	mynotice.error(res.msg);
        			    });
        			    data.field.region = App.cascaderins.getLabel();
        			    data.field.intentionType = type;
        			    data.field.uuid = uuid;
        			    ajax.setData(JSON.stringify(data.field));
        			    ajax.start();
    				    return false;
    			    });
    			}
    		})
    	}
    }
    if($("#cityCodeCascader").length > 0){ 
    	App.cascaderRender();
    }
    App.searchinit();
    App.keyword = App.getQueryString('keyword');
    
    $('.region-select a').click(function() {
    	var region = $(this).data('id');
    	var format = $('.room-select .active-w').data('id')
    	var server = $('.server-select .active-w').data('id')
    	var c = $('#colId').val();
    	var url = '/channel/' + c;
    	if(region != ''){
    		url += '?region=' + region;
    	}
    	if(format != undefined && format != ''){
    		url += region == '' ? '?format=' + format : '&format=' + format;
    	}
    	if(server != undefined && server != ''){
    		url += region == '' ? '?server=' + server : '&server=' + server;
    	}
    	window.location.href = url;
    });
    
    $('.room-select a').click(function() {
    	var format = $(this).data('id');
    	var region = $('.region-select .active-w').data('id')
    	var c = $('#colId').val();
    	var url = '/channel/' + c;
    	if(region != ''){
    		url += '?region=' + region;
    	}
    	if(format != ''){
    		url += region == '' ? '?format=' + format : '&format=' + format;
    	}
    	window.location.href = url;
    });
    
    $('.server-select a').click(function() {
    	var server = $(this).data('id');
    	var region = $('.region-select .active-w').data('id')
    	var c = $('#colId').val();
    	var url = '/channel/' + c;
    	if(region != ''){
    		url += '?region=' + region;
    	}
    	if(server != ''){
    		url += region == '' ? '?server=' + server : '&server=' + server;
    	}
    	window.location.href = url;
    });

    /**
     * 事件监听
     */
    util.event('lay-event', {
    	logout: () => { // 退出登录
    		var ajax = new $ax("/logout", 'get', function (res) {
    			setter.removeToken();
    			location.replace('/');
            }, function (res) {
            	mynotice.error(res.msg);
            });
            ajax.start();
    	},
    	vote: function(){ // 点赞
    		var _that = this;
    		var num = parseInt($(_that).children("p").children("span").text());
			$(_that).children("p").children("span").text(num + 1);
			$(_that).addClass('clickLikeXz');
    		var ajax = new $ax('/api/zp/vote/' + $(_that).attr("data-articleId"), 'post', function (res) {
    				$(_that).attr('lay-event', 'vote_cancel');
            }, function (res) {
            	mynotice.error(res.msg);
            	var num = parseInt($(_that).children("p").children("span").text());
				if(num > 0){
					$(_that).children("p").children("span").text(num - 1);
				}
				$(_that).removeClass('clickLikeXz');
            });
            ajax.start();
    	},
    	vote_cancel: function() { // 取消点赞
    		var _that = this;
    		var num = parseInt($(_that).children("p").children("span").text());
			if(num > 0){
				$(_that).children("p").children("span").text(num - 1);
			}
			$(_that).removeClass('clickLikeXz');
    		var ajax = new $ax('/api/zp/vote_cancel/' + $(_that).attr("data-articleId"), 'post', function (res) {
    			$(_that).attr('lay-event', 'vote');
            }, function (res) {
            	mynotice.error(res.msg);
            	var num = parseInt($(_that).children("p").children("span").text());
				$(_that).children("p").children("span").text(num + 1);
				$(_that).addClass('clickLikeXz');
            });
            ajax.start();
    	},
    	collect: function(){ // 收藏
    		var _that = this;
    		$(_that).addClass('clickLikeXz');
    		$(_that).children("p").text('已收藏');
    		var ajax = new $ax('/api/zp/collect/' + $(_that).attr("data-articleId"), 'post', function (res) {
    			$(_that).attr('lay-event', 'collect_cancel');
            }, function (res) {
            	mynotice.error(res.msg);
            	$(_that).removeClass('clickLikeXz');
    			$(_that).children("p").text('收藏');
            });
            ajax.start();
    	},
    	collect_cancel: function() { // 取消收藏
    		var _that = this;
    		$(_that).removeClass('clickLikeXz');
    		$(_that).children("p").text('收藏');
    		var ajax = new $ax('/api/zp/collect_cancel/' + $(_that).attr("data-articleId"), 'post', function (res) {
    			$(_that).attr('lay-event', 'collect');
            }, function (res) {
            	mynotice.error(res.msg);
            	$(_that).addClass('clickLikeXz');
    			$(_that).children("p").text('已收藏');
            });
            ajax.start();
    	},
    	recMore: function() { // 推荐加载更多
    		App.recMore();
    	},
    	columnMore: function(){ // 栏目加载更多
    		var cid = $(this).data('cid');
    		App.columnMore(cid);
    	},
    	searchMore: function(){ // 搜索加载更多
    		App.searchMore();
    	},
    	searchAuthMore: function(){ // 作者搜索更多
    		App.searchAuthMore();
    	},
    	myMore: function(){ // 用户文章加载更多
    		var id = $(this).data('id');
    		App.myMore(id);
    	},
    	search: function(){ // 搜索
    		var value = $("#searchCon").val();
    		App.search(value);
    	},
    	unfollow: function() { // 取关
    		var _that = this;
    		$(_that).text('+关注');
    		$('#fansNum').text(parseInt($('#fansNum').text()) - 1);
    		var userid = $(_that).data('userid');
    		var ajax = new $ax('/api/zp/takeOff/' + userid, 'post', function (res) {
    			$(_that).attr('lay-event', 'follow');
    			
    			mynotice.success('取消关注成功');
    	    }, function (res) {
    	    	mynotice.error(res.msg);
    	    	$(_that).text('✓已关注');
    			$('#fansNum').text(parseInt($('#fansNum').text()) + 1);
    	    });
    	    ajax.start();
    	},
    	follow: function() { // 关注
    		var _that = this;
    		var userid = $(_that).data('userid');
    		$(_that).text('✓已关注');
    		$('#fansNum').text(parseInt($('#fansNum').text()) + 1);
    		var ajax = new $ax('/api/zp/follow/' + userid, 'post', function (res) {
    			$(_that).attr('lay-event', 'unfollow');
    			mynotice.success('关注成功');
    	    }, function (res) {
    	    	mynotice.error(res.msg);
    	    	$('#fansNum').text(parseInt($('#fansNum').text()) - 1);
    			var userid = $(_that).data('userid');
    	    });
    	    ajax.start();
    	},
    	todetails: function(){ // 内容详情
    		window.open('/details/' + $(this).data('id'));
    	},
    	city: function(){ // 选择城市
    		window.open('/city');
    	},
    	changecity: function(){ // 切换站点
    		var id  = $(this).data('id');
    		var ajax = new $ax('/api/city/change/' + id, 'post', function (res) {
    			window.location.href=document.referrer;
    	    }, function (res) {
    	    	mynotice.error(res.msg);
    	    });
    	    ajax.start();
    	},
    	searchCity: function(){ // 搜索站点
    		var value = $("#cityinput").val();
    		App.searchCity(value);
    	},
    	shoePhone: function() { // 查看手机号
    		$('#btnshow').addClass('layui-hide');
    		$('#telephone').removeClass('layui-hide');
    	},
    	voteMore: function() { // 点赞加载更多
    		var value = $(this).data('id');
    		App.voteMore(value);
    	},  
    	collectMore: function() { // 收藏加载更多
    		var value = $(this).data('id');
    		App.collectMore(value);
    	},
    	putQuestionsTo: function(){ // 我要提问
    		admin.open({
    			type: 1,
    			title: false,
    			offset: 'auto',
    			closeBtn: 0,
    			skin: 'yourclass',
    			area: ['500px', '390px'],
    			content: $('#dialogform').html(),
    			success: function(layero, dIndex){
    				$(layero).children('.layui-layer-content').css('overflow', 'visible'); 
    				/*提交问题*/
    			    form.on('submit(questionsubmit)', function(data){
    			    	if(data.field.question == ''){
    			    		$("#queserro").removeClass('layui-hide');
    		            	return false;
    			    	}
    			    	if(data.field.phone != ''){
    		            	if(!(/^1[3456789]\d{9}$/.test(data.field.phone))){ 
    			    			$("#erroMsg").removeClass('layui-hide');
    		            		return false;
						    } 
    			    	}
    			    	layer.close(dIndex);
    			    	mynotice.load('提交中，请稍后...');
        			    var ajax = new $ax('/zp/question/add', 'post', function (res) {
        			    	mynotice.destroy();
        			    	admin.open({
            	    			type: 1,
            	    			title: false,
            	    			offset: 'auto',
            	    			closeBtn: 0,
            	    			skin: 'yourclass',
            	    			area: '500px',
            	    			content: $('#dialogSuccessform').html(),
            	    			success: function(layero, dIndex){
            	    				$(layero).children('.layui-layer-content').css('overflow', 'visible'); 
            	    			}
            				})
        			    }, function (res) {
        			    	mynotice.destroy();
        			    	mynotice.error(res.msg);
        			    });
        			    ajax.setData(JSON.stringify(data.field));
        			    ajax.start();
    				    return false;
    			    });
    			}
    		})
    	},
    	helpShop: function(){ // 帮助找铺
    		App.helpShop('极速找铺', 0);
    	},
    	transferShop: function(){
    		App.helpShop('闪电转铺', 1);
    	},
    	userShop: function(){
    		App.helpShop('砍价买铺', 2);
    	},
    	delModel: function(){ // 删除弹窗
    		admin.open({
    			type: 1,
    			title: false,
    			offset: 'auto',
    			area: '550px',
    			content: '<article class="infomodel">'+
		    				'<svg t="1586507358558" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4993" width="60" height="60"><path d="M512 64C264.58 64 64 264.58 64 512s200.58 448 448 448 448-200.58 448-448S759.42 64 512 64z m0 752a36 36 0 1 1 36-36 36 36 0 0 1-36 36z m51.83-551.95L548 636a36 36 0 0 1-72 0l-15.83-371.95c-0.1-1.33-0.17-2.68-0.17-4.05a52 52 0 0 1 104 0c0 1.37-0.07 2.72-0.17 4.05z" p-id="4994" fill="#fb6161"></path></svg>'+
		    				'<p class="deleteDialog-title">提示</p>'+
		    				'<p class="deleteDialog-desc">删除后，相关数据将被清除，删除操作不可撤销，请谨慎操作</p>'+
		    				'<div class="deleteDialog-buttonContainer">'+
		    					'<button type="button" class="layui-btn layui-btn-primary" style="width: 100px;" ew-event="closeDialog">取消</button>'+
		    					'<button type="button" class="layui-btn" style="background-color: #fb6161;width: 100px;" lay-event="resdel">确定</button>'+
		    				'</div>'+			
	    				'</article>',
    			success: function(layero, dIndex){
    				$(layero).children('.layui-layer-content').css('overflow', 'visible'); 
    			}
    		})
    	}
    });
    
    $("#searchCon").keydown(function(e){
        if(e.keyCode==13){
        	var value = $("#searchCon").val();
        	App.search(value);
        }
    });
    
    $("#cityinput").keydown(function(e){
        if(e.keyCode==13){
        	var value = $("#cityinput").val();
        	App.searchCity(value);
        }
    });
    
    /*搜索站点监听*/
    $('#cityinput').bind('input propertychange', function () {
	    var value = $(this).val();
	    App.searchCity(value);
	});
    
    $('.postedits').on({
    	mouseover : function(){
    		layer.tips('发布中心', '.postedits', {
    	      	  tips: [3, '#ff4200']
    	      	});
		},
		mouseout : function(){
			layer.closeAll();
		} 
	});
    
    $('.exchange').on({
    	mouseover : function(){
    		layer.tips($(this).data('cityname'), '.exchange', {
    	      	  tips: [3, '#ff4200']
    	      	});
		},
		mouseout : function(){
			layer.closeAll();
		} 
	});
    
    /*监听文章分类*/
    form.on('radio(columnFilter)', function(data){
    	var v = $(data.elem).data('index');
    	$('#formelem').html($('#index_' + v).html());
    	laydate.render({ 
		  elem: '#rangTime', 
		  range: true
		});
    	App.cascaderRender();
    	form.render();
	}); 
    
    /*字数监听*/
    $('#numchange').on('input propertychange', function () {
	    var fizeNum = $(this).val().length;//获取输入字数
	    var maxlength = 30;
	    var chars = $(this).val();
	    if (fizeNum > maxlength) {//如果大于maxlength
	        chars = chars.substr(0, maxlength);//截取字符串（前maxlength）
	        $(this).val(chars);
	        fizeNum = maxlength;
	    }
	    $('.autofit-textarea-content').text(chars);
	    if(fizeNum < 5){
	    	$('.title-tip').html('还需输入<span class="publish-title-bold">'+ (5 - fizeNum) +'</span>个字');
	    }else{
	    	$('.title-tip').html(fizeNum + '/' + maxlength);
	    }
	});
    

    
    /* 搜索框出现 */
    $(".currencySearch").on('click',function(){
        $(".headerNav").hide();
        $(".searchBox").show();
        $("#searchCon").focus();
        $(this).css('border-color','#cdcdcd');
        $(this).find('.headerRt-liA-img').css('background-color','#cdcdcd');
        $(this).unbind();
    })

    /* 关闭搜索框 */
    $(".SearchClose").on('click',function(){
        $(".headerNav").show();
        $(".searchBox").hide();
        $(".HistoryColumn").hide();
        $("#searchCon").val('');
        $(".currencySearch").css('border-color','#ff4200');
        $(".currencySearch").find('.headerRt-liA-img').css('background-color','#ff4200');
        App.curr();
    })
    
    /*历史框显示*/
    $("#searchCon").on('focus',function(){
    	if($('.searchHove .delete li').length > 0){
    		$(".HistoryColumn").slideDown()
    	}
    })

    /*历史框隐藏*/
    $("#searchCon").on('blur',function(){
        $(".HistoryColumn").slideUp()
    })

    /* 点击搜索历史 */
    $(document).delegate(".SearchHistory-li .SearchHistory-liDs", "click", function() {
        $("#searchCon").val($(this).text());
    });
    
    //清除记录功能
    $(".emptyRecord").click(function() {
        var _this = $(this);
        _this.parent('.SearchHistory').hide();
        $.each(App.hisTime, (i, v) => {
        	localStorage.removeItem(v);
        })
        App.searchinit();
        $(".HistoryColumn").slideUp()
    });
    
    form.on('checkbox(reportfilter)', function(data){
    	if(data.elem.checked){
    		$('#otherReasons').removeClass('layui-hide');
    	}else{
    		$('#otherReasons').addClass('layui-hide');
    	}
    });   
    
    /*举报*/
    form.on('submit(reportSubmit)', function(data){
    	var sbStr = '';
        $("input[name='reportContent']").each(function (i, value) {
            if ($(this).prop("checked") == true) {
                sbStr += $(this).val() + ';';
            }
        });
        if(sbStr == ''){
        	mynotice.infoc("请选择举报项");
        	return false;
        }
        data.field.reportContent = sbStr;
    	mynotice.load('提交中，请稍后...');
	    var ajax = new $ax('/zp/report/article', 'post', function (res) {
	    	mynotice.destroy();
	    	mynotice.success('举报已提交');
	    	$("#reportfilterForm")[0].reset();
            form.render();
	    }, function (res) {
	    	mynotice.destroy();
	    	mynotice.error(res.msg);
	    });
	    ajax.setData(JSON.stringify(data.field));
	    ajax.start();
	    return false;
    });
    
});